package com.ioc.trade.entity;

import com.ioc.common.content.AesEntityContent;
import com.ioc.common.enums.ProductEnum;
import com.ioc.common.enums.StatusEnum;
import org.hibernate.annotations.ColumnTransformer;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 提现订单实体：
 *
 * @author ONEC
 * @since 20201013
 */
@Entity
@Table(name = "t_repayment_order")
public class RepaymentOrder implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true)
    private Long id;

    @Column(name = "version", length = 8)
    private Integer version;

    /**
     * 代理商编号
     */
    @Column(name = "agent_id", length = 16)
    private Long agentId;
    /**
     * 商户编号
     */
    @Column(name = "merchant_id", length = 16)
    private Long merchantId;
    /**
     * 商户编号
     */
    @Column(name = "merchant_no", length = 32)
    private String merchantNo;

    /**
     * 通道上游编号
     */
    @Column(name = "channel_merchant_no", length = 32)
    private String channelMerchantNo;

    /**
     * 通道编号
     */
    @Column(name = "channel_id", length = 16)
    private Long channelId;

    /**
     * 类型码编号
     */
    @Column(name = "business_code", length = 32)
    private String businessCode;

    /**
     * 下游订单号
     */
    @Column(name = "external_num", length = 32, unique = true)
    private String externalNum;

    /**
     * 上游订单号
     */
    @Column(name = "trade_num", length = 32, unique = true)
    private String tradeNum;

    /**
     * 平台流水号
     */
    @Column(name = "serial_num", length = 32, unique = true)
    private String serialNum;

    /**
     * 代理商手续费
     */
    @Column(name = "agent_fee", length = 8)
    private BigDecimal agentFee;


    /**
     * 商户手续费（包含固定值）
     */
    @Column(name = "merchant_fee", length = 8)
    private BigDecimal merchantFee;

    /**
     * 通道手续费（包含固定值）
     */
    @Column(name = "channel_fee", length = 8)
    private BigDecimal channelFee;

    /**
     * 商户固定手续费
     */
    @Column(name = "fix_fee", length = 8)
    private BigDecimal fixFee;

    /**
     * 交易金额
     */
    @Column(name = "amount", length = 8)
    private BigDecimal amount;
    /**
     * 优惠信息：jsonobject
     */
    @Column(name = "product", length = 8)
    @Enumerated(EnumType.STRING)
    private ProductEnum product;
    /**
     * 优惠信息：jsonobject
     */
    @Column(name = "business_id", length = 16)
    private String businessId;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;

    /**
     * 完成时间
     */
    @Column(name = "complete_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date completeTime;

    /**
     * 通道完成时间
     */
    @Column(name = "channel_complete_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date channelCompleteTime;

    /**
     * 交易订单状态
     */
    @Column(name = "status", length = 8)
    @Enumerated(EnumType.STRING)
    private StatusEnum status;

    /**
     * 交易卡号
     */
    @Column(name = "card_no")
    @ColumnTransformer(
            read = AesEntityContent.AES_DECRYPT_CARD_NO,
            write = AesEntityContent.AES_ENCRYPT_CARD_NO
    )
    private String cardNo;

    /**
     * 银行名称
     */
    @Column(name = "bank_name", length = 32)
    private String bankName;

    /**
     * 交易手机号
     */
    @ColumnTransformer(
            read = AesEntityContent.AES_DECRYPT_PHONE,
            write = AesEntityContent.AES_ENCRYPT_PHONE
    )
    @Column(name = "phone")
    private String phone;

    /**
     * 产品备注
     */
    @Column(name = "remarks", length = 64)
    private String remarks;


    public RepaymentOrder() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Long getAgentId() {
        return agentId;
    }

    public void setAgentId(Long agentId) {
        this.agentId = agentId;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public String getChannelMerchantNo() {
        return channelMerchantNo;
    }

    public void setChannelMerchantNo(String channelMerchantNo) {
        this.channelMerchantNo = channelMerchantNo;
    }

    public Long getChannelId() {
        return channelId;
    }

    public void setChannelId(Long channelId) {
        this.channelId = channelId;
    }

    public String getBusinessCode() {
        return businessCode;
    }

    public void setBusinessCode(String businessCode) {
        this.businessCode = businessCode;
    }

    public String getExternalNum() {
        return externalNum;
    }

    public void setExternalNum(String externalNum) {
        this.externalNum = externalNum;
    }

    public String getTradeNum() {
        return tradeNum;
    }

    public void setTradeNum(String tradeNum) {
        this.tradeNum = tradeNum;
    }

    public String getSerialNum() {
        return serialNum;
    }

    public void setSerialNum(String serialNum) {
        this.serialNum = serialNum;
    }

    public BigDecimal getAgentFee() {
        return agentFee;
    }

    public void setAgentFee(BigDecimal agentFee) {
        this.agentFee = agentFee;
    }

    public BigDecimal getMerchantFee() {
        return merchantFee;
    }

    public void setMerchantFee(BigDecimal merchantFee) {
        this.merchantFee = merchantFee;
    }

    public BigDecimal getChannelFee() {
        return channelFee;
    }

    public void setChannelFee(BigDecimal channelFee) {
        this.channelFee = channelFee;
    }

    public BigDecimal getFixFee() {
        return fixFee;
    }

    public void setFixFee(BigDecimal fixFee) {
        this.fixFee = fixFee;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public ProductEnum getProduct() {
        return product;
    }

    public void setProduct(ProductEnum product) {
        this.product = product;
    }

    public String getBusinessId() {
        return businessId;
    }

    public void setBusinessId(String businessId) {
        this.businessId = businessId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getCompleteTime() {
        return completeTime;
    }

    public void setCompleteTime(Date completeTime) {
        this.completeTime = completeTime;
    }

    public Date getChannelCompleteTime() {
        return channelCompleteTime;
    }

    public void setChannelCompleteTime(Date channelCompleteTime) {
        this.channelCompleteTime = channelCompleteTime;
    }


    public StatusEnum getStatus() {
        return status;
    }

    public void setStatus(StatusEnum status) {
        this.status = status;
    }

    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getMerchantNo() {
        return merchantNo;
    }

    public void setMerchantNo(String merchantNo) {
        this.merchantNo = merchantNo;
    }
}
